aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/[username]/request/+page.server.js
blob: 15b069622e07d6f1f1a5c477099247a9ccfd5fd9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { redirect } from '@sveltejs/kit';
import { auth, post } from '$lib/utils';

export let load = ({ locals }) => {
	if (!locals.user) throw redirect(307, '/login');
};

export const actions = {
	default: async ({ cookies, locals, request, url }) => {
		let form = Object.fromEntries(await request.formData());
		let { id } = await post('/requests', form, auth(cookies));
		throw redirect(307, `/${locals.user.username}/request/${id}`);
	}
};